import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators';

// import type {Visitor as VisitorType} from '@/models/visitor'
import { Visitor } from 'src/models/visitor';
import { localStorage } from 'src/adapter/localstorage';

@Module<Visitor>({
  stateFactory: true,
  namespaced: true
})
export default class VisitorStateModule extends VuexModule {
  data: unknown = {
    nickName: '',

    mail: '',

    site: '',

    avator: '',

    account: '',

    password: '',

    rememberMe: false,

    edit: true
  };

  @Mutation
  setVisitor(visitor: Visitor) {
    this.data = visitor;
    localStorage.setItem('visitor', visitor);
  }
}
